package com.fingard.dsp.bank.directbank.cmbunion01;

import com.alibaba.fastjson.JSONObject;
import com.fingard.dsp.bank.directConfig.ActSetItem;
import com.fingard.dsp.bank.directbank.cmbunion01.util.BoingPay;
import com.fingard.dsp.bank.reqrespobj.unifiedorder.ReqQueryOrder;
import com.fingard.dsp.bank.reqrespobj.unifiedorder.RetAtsQueryOrder;

public class CMBUnifiedOrder extends CMBUnion01Base {
	public RetAtsQueryOrder queryUnifiedOrder(ReqQueryOrder p_req) {
		RetAtsQueryOrder retAts = new RetAtsQueryOrder();
		retAts.rdSeq = p_req.rdSeq;
		try {
			ActSetItem actItem = this.getBankConfig().getActSetItem(p_req.ownAct, "");
			if (actItem != null) {
				String[] RSApath = actItem.ownCertFilePath.split(",");
	            setConfig(actItem.merchantId,bankFront.getUrl("unifiedPay"),RSApath[0],RSApath[1],actItem.ownKeyStorePath,actItem.oppCertFilePath,actItem.ownKeyPassword);
	         // 查询订单支付状态
	            WriteBankLogLn("招商聚合订单查询："+p_req.outTransID+"---"+p_req.rdSeq);
	            JSONObject ret = BoingPay.getCashier().getPayStatus(p_req.ownAct,p_req.outTransID, p_req.rdSeq);
				WriteBankLogLn("==ret==" + ret);
	            String  pay_result = ret.getString("pay_result");
	            retAts.respCode = "0";
				retAts.respInfo = "success";
				retAts.outTransID  = p_req.outTransID;
				retAts.transState = pay_result;
				retAts.payInfoCode = pay_result;
			} else {
				retAts.respCode = "-1";
				retAts.respInfo = "未找到账号[" + p_req.ownAct + "]商户配置信息!";
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			retAts.respCode = "-1";
			retAts.respInfo = ex.getMessage();
			WriteBankLogLn(ex);
		}
		return retAts;
	}
}
